home *** CD-ROM | disk | FTP | other *** search
- Path: inforamp.net!ts13-11
- From: rmorin@inforamp.net (Randy Charles Morin)
- Newsgroups: comp.lang.c++
- Subject: OWL TEditSearch find-replace has incorrect behavior
- Date: Wed, 20 Mar 96 07:34:30 GMT
- Organization: MiddleWorld SoftWare
- Message-ID: <4iocet$n9v@sam.inforamp.net>
- NNTP-Posting-Host: ts34-09.tor.inforamp.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- Here's the correct behavior.
- This hasn't been excessively tested.
- I hope this helps someone.
- Of course, you needs to work on the message map also.
- I thought about encapsulating these changes,
- but I decided against further development in OWL
- until I've seen 5.0, 4.5 was a big disappointment.
-
- --------
- void MWTextFileEditView::CmEditFind ()
- {
- // INSERT>> Your code here.
- if (!SearchCmd)
- {
- SearchCmd = CM_EDITFIND;
- delete SearchDialog;
- SearchDialog = new TFindDialog(this, SearchData);
- SearchDialog->Create();
- }
- }
-
- void MWTextFileEditView::CmEditReplace ()
- {
- // INSERT>> Your code here.
- if (!SearchCmd)
- {
- SearchCmd = CM_EDITREPLACE;
- delete SearchDialog;
- SearchDialog = new TReplaceDialog(this, SearchData);
- SearchDialog->Create();
- }
- }
-
-
- void MWTextFileEditView::CmEditFindNext ()
- {
- // INSERT>> Your code here.
- if (SearchDialog)
- SearchDialog->UpdateData();
- SearchData.Flags |= FR_FINDNEXT;
- DoSearch();
- }
-
- void MWTextFileEditView::DoSearch()
- {
- do {
- #if defined(BI_PLAT_WIN32)
- unsigned long version = ::GetVersion();
- if (version & 0x80000000L) {
- if (GetApplication())
- GetApplication()->PumpWaitingMessages();
- }
- #endif
- if (SearchData.Flags & FR_REPLACE)
- {
- uint startPos, endPos;
- GetSelection(startPos, endPos);
- char * szBuffer = new char [endPos-startPos+2];
- GetSubText(szBuffer, startPos, endPos);
- string strTemp = string(szBuffer);
- if
- (to_upper(strTemp).compare(to_upper(string(SearchData.FindWhat)))==0)
- Insert(SearchData.ReplaceWith);
- };
-
- if (Search(-1, SearchData.FindWhat,
- bool(SearchData.Flags&FR_MATCHCASE),
- bool(SearchData.Flags&FR_WHOLEWORD),
- !(SearchData.Flags&FR_DOWN)) >= 0) {
- if (SearchData.Flags & (/*FR_REPLACE|*/FR_REPLACEALL))
- Insert(SearchData.ReplaceWith);
- }
- else {
- if (SearchData.Flags & (FR_FINDNEXT|FR_REPLACE)) {
- string errTemplate(GetModule()->LoadString(IDS_CANNOTFIND));
- char errMsg[81];
- wsprintf(errMsg, errTemplate.c_str(), (const char
- far*)SearchData.FindWhat);
- TWindow* w = SearchDialog ? (TWindow*)SearchDialog :
- (TWindow*)this;
- w->MessageBox(errMsg, GetApplication()->GetName(),
- MB_OK |
- MB_ICONEXCLAMATION | MB_TASKMODAL);
- }
- else if (SearchData.Flags & FR_REPLACEALL)
- break;
- }
- } while (SearchData.Flags & FR_REPLACEALL);
- }
-
- LRESULT MWTextFileEditView::EvFindMsg(WPARAM, LPARAM lParam)
- {
- PRECONDITION(SearchDialog);
-
- SearchDialog->UpdateData(lParam);
- if (SearchData.Flags & FR_DIALOGTERM)
- SearchCmd = 0;
-
- else
- DoSearch();
- return 0;
- }
-
- ----------
-
-
- Agrivar
-
- aka Randy Charles Morin
- MiddleWorld SoftWare
- Canada: 1-800-363-3780
- Other: 905-279-2087
-